<template>
    <div>
        <avue-form ref="form" v-model="obj" :option="option"
                   @reset-change="emptytChange"
                   @submit="submit">

        </avue-form>
    </div>
</template>

<script>

    import {baseUploadUrl} from "@/config/env";
    export default {
        data() {
            return {
                obj: {},
                initSuccess: false,
                defaultData: {
                    userId: null,
                    unitPrice: null,
                    num: null,
                    totalPrice: null,
                    orderNo: null,
                    goodsId: null,
                    goodsSpecsId: null,
                    addressId: null,
                    goodsDetails: null,
                    addressDetails: null,
                    state: null,
                    logisticsNo: null,
                    userRemark: null,
                    platformRemark: null,
                    payTime: null,
                    deliverTime: null,
                    successTime: null,

                },
            }
        },
        props: {
            closeDialog: [],
            uri: {},
        },
        computed: {
            option() {
                return {
                    submitBtn: true,
                    emptyBtn: true,
                    submitText: '提交',
                    emptyText: "关闭",
                    column: [
                        {
                            label: '用户id',
                            prop: 'userId',
                            type: 'number',
                            precision: 2,  //保留小数位,
                            minRows: 0,
                            maxRows: 99999999,
                            row: true,
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请输入 用户id",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '单价',
                            prop: 'unitPrice',
                            type: 'number',
                            precision: 2,  //保留小数位,
                            minRows: 0,
                            maxRows: 99999999,
                            row: true,
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请输入 单价",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '购买数量',
                            prop: 'num',
                            type: 'number',
                            precision: 2,  //保留小数位,
                            minRows: 0,
                            maxRows: 99999999,
                            row: true,
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请输入 购买数量",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '总价',
                            prop: 'totalPrice',
                            maxlength: 9999999999,
                            showWordLimit: true,
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请输入 总价",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '订单号',
                            prop: 'orderNo',
                            maxlength: 20,
                            showWordLimit: true,
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请输入 订单号",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '商品id',
                            prop: 'goodsId',
                            maxlength: 32,
                            showWordLimit: true,
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请输入 商品id",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '商品规格id',
                            prop: 'goodsSpecsId',
                            maxlength: 32,
                            showWordLimit: true,
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请输入 商品规格id",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '收货地址id',
                            prop: 'addressId',
                            maxlength: 32,
                            showWordLimit: true,
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请输入 收货地址id",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '商品详情-快照 ',
                            prop: 'goodsDetails',
                            type: 'textarea',
                            maxlength: 0,
                            showWordLimit: true,
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请输入 商品详情-快照 ",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '收货地址详情-快照 ',
                            prop: 'addressDetails',
                            type: 'textarea',
                            maxlength: 0,
                            showWordLimit: true,
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请输入 收货地址详情-快照 ",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '订单状态 ',
                            prop: 'state',
                            type: 'select',
                            dicData: this.dict.get('ORDER_STATE'),
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请选择 订单状态 ",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '物流单号',
                            prop: 'logisticsNo',
                            maxlength: 20,
                            showWordLimit: true,
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请输入 物流单号",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '用户备注 ',
                            prop: 'userRemark',
                            maxlength: 256,
                            showWordLimit: true,
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请输入 用户备注 ",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '平台备注 ',
                            prop: 'platformRemark',
                            maxlength: 256,
                            showWordLimit: true,
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请输入 平台备注 ",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '支付时间',
                            prop: 'payTime',
                            type: 'datetime',
                            format: 'yyyy-MM-dd hh:mm:ss',
                            valueFormat: 'yyyy-MM-dd hh:mm:ss',
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请选择 支付时间",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '发货时间',
                            prop: 'deliverTime',
                            type: 'datetime',
                            format: 'yyyy-MM-dd hh:mm:ss',
                            valueFormat: 'yyyy-MM-dd hh:mm:ss',
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请选择 发货时间",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '完成时间',
                            prop: 'successTime',
                            type: 'datetime',
                            format: 'yyyy-MM-dd hh:mm:ss',
                            valueFormat: 'yyyy-MM-dd hh:mm:ss',
                            span: 20,
                            rules: [{
                                required: true,
                                message: "请选择 完成时间",
                                trigger: "blur"
                            }]
                        },

                    ]
                }
            }
        },
        created() {
            this.obj = this.defaultData;
            this.initSuccess = true;
        },
        methods: {
            emptytChange() {
                this.closeDialog(false);
            },
            submit(form, done) {
                this.crud.post(this.uri.info, this.obj).then((res) => {
                    console.debug(res);
                    if (res.data.code == 200) {
                       this.closeDialog(true);
                    }
                    done(form);
                }).catch((err) => {
                    console.error(err);
                    done(form);
                })
            },
        }
    }
</script>
